package br.ifrn.diacin.ctrlAula.negocio;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import br.ifrn.diacin.ctrlAula.integracao.dao.ReservaDAO;
import br.ifrn.diacin.ctrlAula.integracao.model.Reserva;

@Stateless
public class ConfirmarReservaBean extends GenericBean implements ConfirmarReserva {

    public ConfirmarReservaBean() {
    }
    
    @EJB
    ReservaDAO reservaDao;
  
	@Override
	public List<Reserva> getReservasFuturas() {
		return reservaDao.listarReservasNaoConfirmadas();
	}
	
	@Override
	public void confirmarReservas(List<Integer> reservasConfirmar){
		for(Integer i : reservasConfirmar){
			Reserva r = reservaDao.pesquisarPorId(Reserva.class, i.intValue());
			r.setReservaConfirmada(true);
			getDao().atualizar(r);
		}
	}
	
	@Override
	public void negarReservas(List<Integer> reservasNegar){
		for(Integer i : reservasNegar){
			Reserva r = reservaDao.pesquisarPorId(Reserva.class, i.intValue());
			getDao().excluir(r);
		}
	}

}
